class AcquisitionYearsController < ApplicationController

  before_filter :get_museum

  def index

    @years = Entity.find_by_sql(["select entities.acquired_year, count(entities.acquired_year) as count from entities where entities.acquired_year <> '' and entities.museum_id = ? group by entities.acquired_year order by entities.acquired_year", @museum.id])
    
    @top_years = Entity.find_by_sql(["select entities.acquired_year, count(entities.acquired_year) as count from entities where entities.acquired_year <> '' and entities.museum_id = ? group by entities.acquired_year order by count DESC limit 0, 5", @museum.id])
    
    
    respond_to do |format|
      format.html # show.rhtml
      format.xml  { render :xml => @years.to_xml }
    end
    
  end
  
  def show
  
    @entities = Entity.find(:all, :conditions => ["museum_id = ? and acquired_year = ?", @museum.id, params[:id]])
  
    respond_to do |format|
      format.html # show.rhtml
      format.xml  { render :xml => @museums.to_xml }
    end
  
  end

end
